using System;
using Microsoft.AspNetCore.Mvc;
using MallSystembackend.Api.Model;
using Microsoft.Extensions.Configuration;
using MallSystembackend.Api.Repository;
using MallSystembackend.Api.ParamModel;
namespace MallSystembackend.Api.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class CommodityParametersController : ControllerBase
    {
        public IRepository<CommodityParameters> _commodityParameters;
        public readonly IConfiguration _configuration;
        public CommodityParametersController(IRepository<CommodityParameters> commodityParameters
, IConfiguration configuration)
        {
            _commodityParameters = commodityParameters;
            _configuration = configuration;
        }
        [HttpPost]
        public ActionResult AddParameters(ParamCommodityParameters model)
        {
            var NewParameters = new CommodityParameters
            {
                Parameters = model.Parameters,
                Commodity = model.Commodity
            };
            _commodityParameters.Insert(NewParameters);
            return Ok(new
            {
                Code = 1000,
                Data = NewParameters,
                Msg = "添加成功"
            });

        }
    }
}